function closeEditor() {
	document.getElementById('dayShiftEditor').style.display = 'none';
}
var userRowIndex;
var timeLineIds = new Array();

function openUserDayEditor(userId, userName, trackId, shiftId, dayIndex, weekId, rowIndex) {
	document.getElementById('dayShiftEditor').style.display = 'block';
	$('#scheduleDays').find(':checkbox').attr('checked',false);
	$("#selectall").attr('checked', false);
	resetTimeListId();
	$("#formUserId").val(userId);
	$("#formWeekId").val(weekId);
	userRowIndex = rowIndex;
	$("#scheduleUserName").text(userName);
	$("#dayIndex"+ dayIndex).attr('checked', true);
	$("#timeLineId" + dayIndex).val($("#timeLine" +userRowIndex + dayIndex).val());
	
	setSelect('shift_selector',shiftId);
	setSelect('track_selector',trackId);
}

function setTimeLineId(daySelect, dayIndex) {
	if (daySelect.checked) {
		$("#timeLineId" + dayIndex).val($("#timeLine" +userRowIndex + dayIndex).val());
	} else {
		$("#timeLineId" + dayIndex).val("");
	}
}
function resetTimeListId() {
	for (var i = 0; i <7; i++) {
		$("#timeLineId" + i).val("");
	}
}
$(function () {
	 $('#selectall').click(function () {
	  $('#scheduleDays').find(':checkbox').attr('checked', this.checked);
	  if (this.checked) {
		  for (var index=0; index < 7; index++) {
			  $("#timeLineId" + index).val($("#timeLine" +userRowIndex + index).val());
		  }
	  }
	  else {
		  for (var index=0; index < 7; index++) {
			  $("#timeLineId" + index).val("");
		  }
	  }
	 });
});

function setSelect(id, value) {
		var sel = document.getElementById(id);
		var option, options = sel.options;
		var i = options.length;
		while (i--) {
		  option = options[i];
		  option.selected = (option.value == value)? true : false;
		}
	}

function showDiv(thisVar) {
	$("#div" + thisVar.id).show();
}
function hideDiv(thisVar) {
	$("#div" + thisVar.id).hide();
}